﻿using System;
using SharePoint.DataMapper;

namespace SharePoint.DataMapper.Metal
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.WriteLine("SharePoint.DataMapper.Metal");
			if (args.Length == 1)
			{
				Console.WriteLine("List URL: " + args[0]);
				try
				{
					using (ListContext context = new ListContext(args[0]))
					{
						CodeFileGenerator generator = new CodeFileGenerator(context.List);
						generator.Generate();
					}
				}
				catch (Exception ex)
				{
					Console.WriteLine(ex.Message);
					Console.WriteLine(ex.StackTrace);
				}
			}
			else
			{
				Console.WriteLine("Usage: SharePoint.DataMapper.Metal <SharePoint List Url>");
				Console.WriteLine("Example: SharePoint.DataMapper.Metal http://localhost/Lists/News/");
			}
		}
	}
}